<?php
//模型
class CourseCardModel extends MY_Model {
	function __construct(){
		parent::__construct();
		$this->table = 'course_card';
	}
	
	
	function get_list($arr,$page=1,$size=10){
		$where = '1';
		if(isset($arr['cid']) && !empty($arr['cid'])){
			$where .= " AND course_id= '{$arr['course_id']}'";
		}
		
		$sql  = "select * from ".$this->db->dbprefix.$this->table." where {$where} limit ".($page-1)*$size.",{$size}";

		$query = $this->db->query($sql);
		$res = $query->result_array();
		
		
		$sql  = "select count(id) as num from ".$this->db->dbprefix.$this->table." where {$where} ";
		$query = $this->db->query($sql);
		$row = $query->row_array();
		$count = $row['num'];
		
		return array('list'=>$res,'count'=>$count);
	}

	
	function course_get_list($cid){
		
		$where = " course_id= '{$cid}'";
		
		$sql  = "select * from ".$this->db->dbprefix.$this->table." where {$where} limit 1000";

		$query = $this->db->query($sql);
		$res = $query->result_array();
		
		return $res;
	}
}

